<template>
  <div class="u-page u-box u-text-center u-lh-2 u-pt-50">
    <!-- 图标 -->
    <div>
      <u-icon
        :class="info.type == 'success' ? 'u-cl-primary' : 'u-cl-main'"
        :name="info.type == 'success' ? 'checkmark-circle' : 'info-circle'"
        size="100"
      ></u-icon>
    </div>

    <!-- 标题 -->
    <div
      class="u-fz-20 u-font-bold"
      :class="info.type == 'success' ? 'u-cl-primary' : 'u-cl-main'"
    >
      {{ info.title }}
    </div>

    <!-- 提示 -->
    <div class="u-cl-tips u-mt-15 u-mb-15" v-html="info.tips"></div>

    <!-- 按钮 -->
    <div style="bottom: 100rpx;position: fixed;width: 90%;">
      <div style="margin-top: 40rpx;">
        <u-button type="primary" shape="circle" @click="onClick(info.action)">
          {{ info.btnText }}
        </u-button>
      </div>

      <!-- 关闭按钮 -->
      <div style="margin-top: 40rpx;" v-if="!showCloseBtn">
        <u-button type="info" shape="circle" @click="onClick('toWorkingPlatform')">
          关闭
        </u-button>
      </div>
    </div>

  </div>
</template>

<script>
export default {
  data() {
    return {
      info: {},
      showCloseBtn: false, // 关闭按钮(默认显示)
      MainDocUnid: '',// 【主】文档ID
      SubDocUnid: '',// 【子】文档ID
      Subject: '',// 推广名称
      PartnerName: '',// 参与者昵称
      modes: {
        
		// 第1、2次验收不通过回退，操作通知
		5: {
          type: "success",
          title: "提交成功!",
          tips: "已成功退回，等待拍档再次提交任务成果!",
          btnText: "关闭",
          action: "toWorkingPlatform",
        },
		
		// 核算无误，操作通知
		7: {
          type: "success",
          title: "提交成功!",
          tips: "",
          btnText: "关闭",
          action: "toWorkingPlatform",
        },
        
      },
    };
  },

  onLoad(options) {
    let mode =  options.mode;

    // 【主】文档ID
    this.MainDocUnid = options.MainDocUnid;

    // 【子】文档ID
    this.SubDocUnid = options.SubDocUnid;

    if(mode == 5 || mode == 7){
      this.info = this.modes[mode];
      this.showCloseBtn = true;// 隐藏关闭按钮
    }

    // 支付“推广费用”成功任务发布成功，操作通知
    if(mode == 1){
      this.info = {
        type: "success",
        title: "完成支付！",
        tips: '您的<span style="color:red;">' + options.Subject + '</span>任务已发布，平台已自动分配给所有符合条件的拍档，请耐心等待报名信息！<br/>温馨提示：分享给好友或微信群，让更多小伙伴了解您的推广活动哦！',
        btnText: "去分享",
        action: "shareTask",
      }
    }

    // 报名成功，操作通知
    if(mode == 2){
      this.info = {
        type: "success",
        title: "已获得推广名额！",
        tips: '<span style="color:red;">' +options.Subject+'</span>任务已启动，请您在<span style="color:red;">' + options.EndTime + '</span>前（含当天）按照<span style="color:red;">' + options.InitiatorName + '</span>的验收要求提交成果，验收成功后发放本次推广费用！<br/>温馨提示：查看推广进度了解您的工作任务，任务完成后，您可点击下方按钮或移步“工作台”的“工作待办”处提交推广成果！',
        btnText: "提交推广成果",
        action: "submitResults",
      }
    }

    // 提交成果，操作通知
    if(mode == 3){
      this.showCloseBtn = true;// 隐藏关闭按钮
      this.info = {
        type: "success",
        title: "提交成功！",
        tips: '<span style="color:red;">' + options.Subject + '</span>的推广成果已提交，请耐心等待<span style="color:red;">' + options.InspectorName + '</span>验收，验收通过后本次推广奖励将自动转入您的账户！',
        btnText: "关闭",
        action: "toWorkingPlatform",
      }
    }

    // 验收通过，操作通知
    if(mode == 4){
      this.info = {
        type: "success",
        title: "通过验收！",
        tips: '已扣除<span style="color:red;">' + options.Subject + '</span>任务的<span style="color:red;">' + options.Rewards + '</span>元推广费用（剩余<span style="color:red;">' + options.TotalRemainCost + '</span>元）！',
        btnText: "查看进度",
        action: "viewProgress",
      }
    }

    // 验收两次不通过回收任务，操作通知
    if(mode == 6){
      this.showCloseBtn = true;// 隐藏关闭按钮
      this.info = {
        type: "success",
        title: "任务已回收",
        tips: '<span style="color:red;">' + options.PartnerName + '</span>负责的<span style="color:red;">' + options.Subject + '</span>推广任务已回收。',
        btnText: "关闭",
        action: "toWorkingPlatform",
      }
    }

  },

  methods: {
    /**
     * 按钮点击
     */
    onClick(action) {
      switch (action) {
		  
		// 去工作台---关闭按钮
		case "toWorkingPlatform":
		  uni.reLaunch({url:'/pages_tabbar_contact/personal_contact/WorkBench?backto=personalIndex'});
		  break; 
		
		// 去分享
		case "shareTask":
		  this.$u.route('/pages_private_scene2/Promote2/SignUp?docUnid='+this.MainDocUnid);
		  break;
		  
		// 查看进度---报表
        case "viewProgress":
          this.$u.route('/pages_private_scene2/Promote2/Reports?docUnid='+this.MainDocUnid);
          break;
		  
		// 提交推广成果
        case "submitResults":
          this.$u.route('/pages_private_scene2/Promote2/SubmitResults?docUnid='+this.SubDocUnid);
          break;  
        
		default:
          break;
      }
    },
	
  },
};
</script>

<style lang="scss" scoped></style>
